package thinkingJava.chapter11;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import thinkingJava.chapter14.Cat;
import thinkingJava.chapter14.Cymric;
import thinkingJava.chapter14.Dog;
import thinkingJava.chapter14.Hamster;
import thinkingJava.chapter14.Mouse;
import thinkingJava.chapter14.Pet;
import thinkingJava.chapter14.Pug;
import thinkingJava.chapter14.Rat;

public class MapOfList {
	public static Map<Person,List<? extends Pet>>
		petPeople = new HashMap<Person,List<? extends Pet>>();
	static {
		petPeople.put(new Person("Dawm"),
				Arrays.asList(new Cymric("Cymric"),new Cat("Fees"),new Dog("King Mao")));
		petPeople.put(new Person("Lily"),
				Arrays.asList(new Hamster("Mosico"),new Rat("Rabit")));
		petPeople.put(new Person("Damon"),
				Arrays.asList(new Mouse("Miomi"),new Pug("Elina")));
	}
	public static void main(String[] args) {
		print("People -----" + petPeople.keySet());
		print("Pets -----" + petPeople.values());
		Iterator<Person> it = petPeople.keySet().iterator();
		while (it.hasNext()) {
			print(it.next());
		}
		for (Person p : petPeople.keySet()) {
			print(p + " ====>> ");
			for (Pet pet : petPeople.get(p)) {
				print(pet+"--|");
			}
		}
	}
	public static void print(Object o) {
		System.out.println(o);
	}
}
